home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / AlexNeXTSTEPSource / Source / Chapter4_AppKit / AppKitDemo.m < prev    next >
Text File  |  1995-06-12  |  1KB  |  47 lines

  1. #import <appkit/appkit.h>
  2.  
  3. // a program to demonstrate how to display
  4. // a window and a menu with a Quit option
  5.  
  6. void main(void)
  7. {
  8.     // create an application object
  9.     // to establish connection to
  10.     // Window Server
  11.     id NXApp = [Application new];
  12.     id theWindow;
  13.     id theMenu;
  14.     id theMenuCell;
  15.  
  16.     // create buffered window at default
  17.     // location with minituarize button
  18.     // and title bar
  19.     theWindow = [ [Window alloc]
  20.         initContent:NULL
  21.         style: NX_RESIZEBARSTYLE
  22.         backing:NX_BUFFERED
  23.         buttonMask:NX_MINIATURIZEBUTTONMASK
  24.         defer:YES];
  25.  
  26.     // create the menu
  27.     theMenu = [ [Menu alloc]
  28.         initTitle: "AppKitDemo"];
  29.     // create the menu option
  30.     theMenuCell = [theMenu addItem:"Quit"
  31.         action:@selector(terminate:)
  32.         keyEquivalent:'q'];
  33.     // set NXApp as target of the menucell
  34.     [theMenuCell setTarget:NXApp];
  35.  
  36.     // resize menu to accomodate menu option
  37.     [theMenu sizeToFit];
  38.     [NXApp setMainMenu:theMenu];
  39.  
  40.     // send the window to the front
  41.     // and display it
  42.     [theWindow makeKeyAndOrderFront:nil];
  43.  
  44.     // go into event loop to wait for events
  45.     [NXApp run];
  46. }
  47.